<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>缓存的有效期与淘汰策略 | 课程简介</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../C06-Cache/CachePatterns.html" />
    
    
    <link rel="prev" href="../C06-Cache/CacheData.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="6.3"
        data-chapter-title="缓存的有效期与淘汰策略"
        data-filepath="C06-Cache/CacheTTLAndEviction.md"
        data-basepath=".."
        data-revision="Mon May 27 2019 03:35:45 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        课程简介
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="C01-Introduction/index.html">
            
                
                    <a href="../C01-Introduction/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        项目介绍
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="C01-Introduction/AboutToutiaoWebVM.html">
            
                
                    <a href="../C01-Introduction/AboutToutiaoWebVM.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        ToutiaoWeb虚拟机使用说明
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="C01-Introduction/PycharmRemoteDevelop.html">
            
                
                    <a href="../C01-Introduction/PycharmRemoteDevelop.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        Pycharm远程开发
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="C01-Introduction/AboutProject.html">
            
                
                    <a href="../C01-Introduction/AboutProject.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        产品与开发
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="C02-Database/index.html">
            
                
                    <a href="../C02-Database/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        数据库
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="C02-Database/DatabaseDesign.html">
            
                
                    <a href="../C02-Database/DatabaseDesign.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        数据库设计
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="C02-Database/ORM.html">
            
                
                    <a href="../C02-Database/ORM.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        理解ORM
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="C02-Database/SQLAlchemyMapping.html">
            
                
                    <a href="../C02-Database/SQLAlchemyMapping.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        SQLAlchemy映射构建
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="C02-Database/SQLAlchemyOperations.html">
            
                
                    <a href="../C02-Database/SQLAlchemyOperations.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        SQLAlchemy操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="C02-Database/DatabaseTheory.html">
            
                
                    <a href="../C02-Database/DatabaseTheory.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        数据库理论
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="C02-Database/DistributedID.html">
            
                
                    <a href="../C02-Database/DistributedID.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        分布式ID
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="C02-Database/DatabaseOptimize.html">
            
                
                    <a href="../C02-Database/DatabaseOptimize.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                        数据库优化
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="C02-Database/Redis.html">
            
                
                    <a href="../C02-Database/Redis.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.8.</b>
                        
                        Redis
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="C03-Gitflow/index.html">
            
                
                    <a href="../C03-Gitflow/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        Git工作流
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="C03-Gitflow/Gitflow.html">
            
                
                    <a href="../C03-Gitflow/Gitflow.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        Gitflow
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="C03-Gitflow/AboutGit.html">
            
                
                    <a href="../C03-Gitflow/AboutGit.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        Git总结
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="C03-Gitflow/ProjectDirectory.html">
            
                
                    <a href="../C03-Gitflow/ProjectDirectory.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        工程目录
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="C03-Gitflow/DebugMethod.html">
            
                
                    <a href="../C03-Gitflow/DebugMethod.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        调试方法
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="C04-JWT/index.html">
            
                
                    <a href="../C04-JWT/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        JWT
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="C04-JWT/JWT.html">
            
                
                    <a href="../C04-JWT/JWT.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        JWT &amp; JWS &amp; JWE
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="C04-JWT/PythonLib.html">
            
                
                    <a href="../C04-JWT/PythonLib.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        PythonLib
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="C04-JWT/Implement.html">
            
                
                    <a href="../C04-JWT/Implement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        实施方案
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="C04-JWT/Forbbiden.html">
            
                
                    <a href="../C04-JWT/Forbbiden.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        禁用问题
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="C05-OSS/index.html">
            
                
                    <a href="../C05-OSS/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        对象存储
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="C05-OSS/Qiniu.html">
            
                
                    <a href="../C05-OSS/Qiniu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        七牛云存储
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="C05-OSS/CDN.html">
            
                
                    <a href="../C05-OSS/CDN.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        CDN
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="C06-Cache/index.html">
            
                
                    <a href="../C06-Cache/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        缓存
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="C06-Cache/CacheArchitecture.html">
            
                
                    <a href="../C06-Cache/CacheArchitecture.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        缓存的架构
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="C06-Cache/CacheData.html">
            
                
                    <a href="../C06-Cache/CacheData.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        缓存的数据
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="6.3" data-path="C06-Cache/CacheTTLAndEviction.html">
            
                
                    <a href="../C06-Cache/CacheTTLAndEviction.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        缓存的有效期与淘汰策略
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="C06-Cache/CachePatterns.html">
            
                
                    <a href="../C06-Cache/CachePatterns.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        缓存模式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="C06-Cache/CacheProblems.html">
            
                
                    <a href="../C06-Cache/CacheProblems.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        缓存问题
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="C06-Cache/ProjectCacheAndStorageDesign.html">
            
                
                    <a href="../C06-Cache/ProjectCacheAndStorageDesign.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.6.</b>
                        
                        项目缓存与Redis持久存储设计
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="C06-Cache/ProjectCacheImplement.html">
            
                
                    <a href="../C06-Cache/ProjectCacheImplement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.7.</b>
                        
                        项目缓存实现
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="C06-Cache/ProjectRedisStorageImplement.html">
            
                
                    <a href="../C06-Cache/ProjectRedisStorageImplement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.8.</b>
                        
                        项目Redis持久存储实现
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" data-path="C07-APScheduler/index.html">
            
                
                    <a href="../C07-APScheduler/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        APScheduler
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="C07-APScheduler/APSchedulerTutorial.html">
            
                
                    <a href="../C07-APScheduler/APSchedulerTutorial.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        APScheduler使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="C07-APScheduler/FixStatistics.html">
            
                
                    <a href="../C07-APScheduler/FixStatistics.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        定时修正统计数据
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="8" data-path="C08-RPC/index.html">
            
                
                    <a href="../C08-RPC/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        RPC
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="8.1" data-path="C08-RPC/AboutRPC.html">
            
                
                    <a href="../C08-RPC/AboutRPC.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.1.</b>
                        
                        RPC简介
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="C08-RPC/gRPC.html">
            
                
                    <a href="../C08-RPC/gRPC.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.2.</b>
                        
                        gRPC
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="C08-RPC/ProtocolBuffers.html">
            
                
                    <a href="../C08-RPC/ProtocolBuffers.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.3.</b>
                        
                        Protocol Buffers
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="C08-RPC/RecoSysIDL.html">
            
                
                    <a href="../C08-RPC/RecoSysIDL.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.4.</b>
                        
                        推荐系统接口定义
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.5" data-path="C08-RPC/Server.html">
            
                
                    <a href="../C08-RPC/Server.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.5.</b>
                        
                        服务端
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.6" data-path="C08-RPC/Client.html">
            
                
                    <a href="../C08-RPC/Client.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.6.</b>
                        
                        客户端
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.7" data-path="C08-RPC/ToutiaoAPIViewImplement.html">
            
                
                    <a href="../C08-RPC/ToutiaoAPIViewImplement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.7.</b>
                        
                        头条首页新闻推荐接口编写
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="9" data-path="C09-IM/index.html">
            
                
                    <a href="../C09-IM/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.</b>
                        
                        即时通信
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="9.1" data-path="C09-IM/AboutIM.html">
            
                
                    <a href="../C09-IM/AboutIM.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.1.</b>
                        
                        即时通信简介
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9.2" data-path="C09-IM/WebSocket.html">
            
                
                    <a href="../C09-IM/WebSocket.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.2.</b>
                        
                        WebSocket
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9.3" data-path="C09-IM/SocketIO.html">
            
                
                    <a href="../C09-IM/SocketIO.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.3.</b>
                        
                        Socket.IO
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9.4" data-path="C09-IM/Chat.html">
            
                
                    <a href="../C09-IM/Chat.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.4.</b>
                        
                        头条聊天服务实现
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9.5" data-path="C09-IM/MessagePush.html">
            
                
                    <a href="../C09-IM/MessagePush.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.5.</b>
                        
                        头条在线消息推送实现
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="10" data-path="C10-Elasticsearch/index.html">
            
                
                    <a href="../C10-Elasticsearch/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.</b>
                        
                        Elasticsearch
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="10.1" data-path="C10-Elasticsearch/Introduction.html">
            
                
                    <a href="../C10-Elasticsearch/Introduction.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.1.</b>
                        
                        简介与原理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.2" data-path="C10-Elasticsearch/ConceptAndCluster.html">
            
                
                    <a href="../C10-Elasticsearch/ConceptAndCluster.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.2.</b>
                        
                        概念与集群
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.3" data-path="C10-Elasticsearch/AnalysisIK.html">
            
                
                    <a href="../C10-Elasticsearch/AnalysisIK.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.3.</b>
                        
                        IK中文分析器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.4" data-path="C10-Elasticsearch/IndexAndType.html">
            
                
                    <a href="../C10-Elasticsearch/IndexAndType.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.4.</b>
                        
                        索引与类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.5" data-path="C10-Elasticsearch/Document.html">
            
                
                    <a href="../C10-Elasticsearch/Document.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.5.</b>
                        
                        文档
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.6" data-path="C10-Elasticsearch/Logstash.html">
            
                
                    <a href="../C10-Elasticsearch/Logstash.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.6.</b>
                        
                        Logstash导入数据
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.7" data-path="C10-Elasticsearch/Query.html">
            
                
                    <a href="../C10-Elasticsearch/Query.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.7.</b>
                        
                        查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.8" data-path="C10-Elasticsearch/ToutiaoSearchImplement.html">
            
                
                    <a href="../C10-Elasticsearch/ToutiaoSearchImplement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.8.</b>
                        
                        头条全文检索实现
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.9" data-path="C10-Elasticsearch/Suggest.html">
            
                
                    <a href="../C10-Elasticsearch/Suggest.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.9.</b>
                        
                        suggest查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.10" data-path="C10-Elasticsearch/ToutiaoSuggestImplement.html">
            
                
                    <a href="../C10-Elasticsearch/ToutiaoSuggestImplement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.10.</b>
                        
                        头条suggest查询实现
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="11" data-path="C11-Unittest.html">
            
                
                    <a href="../C11-Unittest.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>11.</b>
                        
                        单元测试
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="12" data-path="C12-Deployment/index.html">
            
                
                    <a href="../C12-Deployment/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.</b>
                        
                        部署相关
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="12.1" data-path="C12-Deployment/Gunicorn.html">
            
                
                    <a href="../C12-Deployment/Gunicorn.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.1.</b>
                        
                        Gunicorn
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="12.2" data-path="C12-Deployment/Supervisor.html">
            
                
                    <a href="../C12-Deployment/Supervisor.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.2.</b>
                        
                        Supervisor
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >课程简介</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x7F13;&#x5B58;&#x6709;&#x6548;&#x671F;&#x4E0E;&#x6DD8;&#x6C70;&#x7B56;&#x7565;">&#x7F13;&#x5B58;&#x6709;&#x6548;&#x671F;&#x4E0E;&#x6DD8;&#x6C70;&#x7B56;&#x7565;</h1>
<h2 id="&#x6709;&#x6548;&#x671F;-ttl-&#xFF08;time-to-live">&#x6709;&#x6548;&#x671F; TTL &#xFF08;Time to live)</h2>
<p>&#x8BBE;&#x7F6E;&#x6709;&#x6548;&#x671F;&#x7684;&#x4F5C;&#x7528;&#xFF1A;</p>
<ol>
<li>&#x8282;&#x7701;&#x7A7A;&#x95F4;</li>
<li>&#x505A;&#x5230;&#x6570;&#x636E;&#x5F31;&#x4E00;&#x81F4;&#x6027;&#xFF0C;&#x6709;&#x6548;&#x671F;&#x5931;&#x6548;&#x540E;&#xFF0C;&#x53EF;&#x4EE5;&#x4FDD;&#x8BC1;&#x6570;&#x636E;&#x7684;&#x4E00;&#x81F4;&#x6027;</li>
</ol>
<h4 id="redis&#x7684;&#x8FC7;&#x671F;&#x7B56;&#x7565;">Redis&#x7684;&#x8FC7;&#x671F;&#x7B56;&#x7565;</h4>
<p>&#x8FC7;&#x671F;&#x7B56;&#x7565;&#x901A;&#x5E38;&#x6709;&#x4EE5;&#x4E0B;&#x4E09;&#x79CD;&#xFF1A;</p>
<ul>
<li><p><strong>&#x5B9A;&#x65F6;&#x8FC7;&#x671F;</strong></p>
<p>  &#x6BCF;&#x4E2A;&#x8BBE;&#x7F6E;&#x8FC7;&#x671F;&#x65F6;&#x95F4;&#x7684;key&#x90FD;&#x9700;&#x8981;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5B9A;&#x65F6;&#x5668;&#xFF0C;&#x5230;&#x8FC7;&#x671F;&#x65F6;&#x95F4;&#x5C31;&#x4F1A;&#x7ACB;&#x5373;&#x6E05;&#x9664;&#x3002;&#x8BE5;&#x7B56;&#x7565;&#x53EF;&#x4EE5;&#x7ACB;&#x5373;&#x6E05;&#x9664;&#x8FC7;&#x671F;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x5BF9;&#x5185;&#x5B58;&#x5F88;&#x53CB;&#x597D;&#xFF1B;&#x4F46;&#x662F;&#x4F1A;&#x5360;&#x7528;&#x5927;&#x91CF;&#x7684;CPU&#x8D44;&#x6E90;&#x53BB;&#x5904;&#x7406;&#x8FC7;&#x671F;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x4ECE;&#x800C;&#x5F71;&#x54CD;&#x7F13;&#x5B58;&#x7684;&#x54CD;&#x5E94;&#x65F6;&#x95F4;&#x548C;&#x541E;&#x5410;&#x91CF;&#x3002;</p>
<pre><code class="lang-python">  setex(<span class="hljs-string">&apos;a&apos;</span>, <span class="hljs-number">300</span>, <span class="hljs-string">&apos;aval&apos;</span>)
  setex(<span class="hljs-string">&apos;b&apos;</span>, <span class="hljs-number">600</span>, <span class="hljs-string">&apos;bval&apos;</span>)
</code></pre>
</li>
<li><p><strong>&#x60F0;&#x6027;&#x8FC7;&#x671F;</strong></p>
<p>  &#x53EA;&#x6709;&#x5F53;&#x8BBF;&#x95EE;&#x4E00;&#x4E2A;key&#x65F6;&#xFF0C;&#x624D;&#x4F1A;&#x5224;&#x65AD;&#x8BE5;key&#x662F;&#x5426;&#x5DF2;&#x8FC7;&#x671F;&#xFF0C;&#x8FC7;&#x671F;&#x5219;&#x6E05;&#x9664;&#x3002;&#x8BE5;&#x7B56;&#x7565;&#x53EF;&#x4EE5;&#x6700;&#x5927;&#x5316;&#x5730;&#x8282;&#x7701;CPU&#x8D44;&#x6E90;&#xFF0C;&#x5374;&#x5BF9;&#x5185;&#x5B58;&#x975E;&#x5E38;&#x4E0D;&#x53CB;&#x597D;&#x3002;&#x6781;&#x7AEF;&#x60C5;&#x51B5;&#x53EF;&#x80FD;&#x51FA;&#x73B0;&#x5927;&#x91CF;&#x7684;&#x8FC7;&#x671F;key&#x6CA1;&#x6709;&#x518D;&#x6B21;&#x88AB;&#x8BBF;&#x95EE;&#xFF0C;&#x4ECE;&#x800C;&#x4E0D;&#x4F1A;&#x88AB;&#x6E05;&#x9664;&#xFF0C;&#x5360;&#x7528;&#x5927;&#x91CF;&#x5185;&#x5B58;&#x3002;</p>
</li>
<li><p><strong>&#x5B9A;&#x671F;&#x8FC7;&#x671F;</strong></p>
<p>  &#x6BCF;&#x9694;&#x4E00;&#x5B9A;&#x7684;&#x65F6;&#x95F4;&#xFF0C;&#x4F1A;&#x626B;&#x63CF;&#x4E00;&#x5B9A;&#x6570;&#x91CF;&#x7684;&#x6570;&#x636E;&#x5E93;&#x7684;expires&#x5B57;&#x5178;&#x4E2D;&#x4E00;&#x5B9A;&#x6570;&#x91CF;&#x7684;key&#xFF0C;&#x5E76;&#x6E05;&#x9664;&#x5176;&#x4E2D;&#x5DF2;&#x8FC7;&#x671F;&#x7684;key&#x3002;&#x8BE5;&#x7B56;&#x7565;&#x662F;&#x524D;&#x4E24;&#x8005;&#x7684;&#x4E00;&#x4E2A;&#x6298;&#x4E2D;&#x65B9;&#x6848;&#x3002;&#x901A;&#x8FC7;&#x8C03;&#x6574;&#x5B9A;&#x65F6;&#x626B;&#x63CF;&#x7684;&#x65F6;&#x95F4;&#x95F4;&#x9694;&#x548C;&#x6BCF;&#x6B21;&#x626B;&#x63CF;&#x7684;&#x9650;&#x5B9A;&#x8017;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x4E0D;&#x540C;&#x60C5;&#x51B5;&#x4E0B;&#x4F7F;&#x5F97;CPU&#x548C;&#x5185;&#x5B58;&#x8D44;&#x6E90;&#x8FBE;&#x5230;&#x6700;&#x4F18;&#x7684;&#x5E73;&#x8861;&#x6548;&#x679C;&#x3002;</p>
<blockquote>
<p>expires&#x5B57;&#x5178;&#x4F1A;&#x4FDD;&#x5B58;&#x6240;&#x6709;&#x8BBE;&#x7F6E;&#x4E86;&#x8FC7;&#x671F;&#x65F6;&#x95F4;&#x7684;key&#x7684;&#x8FC7;&#x671F;&#x65F6;&#x95F4;&#x6570;&#x636E;&#xFF0C;&#x5176;&#x4E2D;&#xFF0C;key&#x662F;&#x6307;&#x5411;&#x952E;&#x7A7A;&#x95F4;&#x4E2D;&#x7684;&#x67D0;&#x4E2A;&#x952E;&#x7684;&#x6307;&#x9488;&#xFF0C;value&#x662F;&#x8BE5;&#x952E;&#x7684;&#x6BEB;&#x79D2;&#x7CBE;&#x5EA6;&#x7684;UNIX&#x65F6;&#x95F4;&#x6233;&#x8868;&#x793A;&#x7684;&#x8FC7;&#x671F;&#x65F6;&#x95F4;&#x3002;&#x952E;&#x7A7A;&#x95F4;&#x662F;&#x6307;&#x8BE5;Redis&#x96C6;&#x7FA4;&#x4E2D;&#x4FDD;&#x5B58;&#x7684;&#x6240;&#x6709;&#x952E;&#x3002;</p>
</blockquote>
</li>
</ul>
<p><strong>Redis&#x4E2D;&#x540C;&#x65F6;&#x4F7F;&#x7528;&#x4E86;&#x60F0;&#x6027;&#x8FC7;&#x671F;&#x548C;&#x5B9A;&#x671F;&#x8FC7;&#x671F;&#x4E24;&#x79CD;&#x8FC7;&#x671F;&#x7B56;&#x7565;&#x3002;</strong></p>
<p>Redis&#x8FC7;&#x671F;&#x5220;&#x9664;&#x91C7;&#x7528;&#x7684;&#x662F;&#x5B9A;&#x671F;&#x5220;&#x9664;&#xFF0C;&#x9ED8;&#x8BA4;&#x662F;&#x6BCF;100ms&#x68C0;&#x6D4B;&#x4E00;&#x6B21;&#xFF0C;&#x9047;&#x5230;&#x8FC7;&#x671F;&#x7684;key&#x5219;&#x8FDB;&#x884C;&#x5220;&#x9664;&#xFF0C;&#x8FD9;&#x91CC;&#x7684;&#x68C0;&#x6D4B;&#x5E76;&#x4E0D;&#x662F;&#x987A;&#x5E8F;&#x68C0;&#x6D4B;&#xFF0C;&#x800C;&#x662F;&#x968F;&#x673A;&#x68C0;&#x6D4B;&#x3002;&#x90A3;&#x8FD9;&#x6837;&#x4F1A;&#x4E0D;&#x4F1A;&#x6709;&#x6F0F;&#x7F51;&#x4E4B;&#x9C7C;&#xFF1F;&#x663E;&#x7136;Redis&#x4E5F;&#x8003;&#x8651;&#x5230;&#x4E86;&#x8FD9;&#x4E00;&#x70B9;&#xFF0C;&#x5F53;&#x6211;&#x4EEC;&#x53BB;&#x8BFB;/&#x5199;&#x4E00;&#x4E2A;&#x5DF2;&#x7ECF;&#x8FC7;&#x671F;&#x7684;key&#x65F6;&#xFF0C;&#x4F1A;&#x89E6;&#x53D1;Redis&#x7684;&#x60F0;&#x6027;&#x5220;&#x9664;&#x7B56;&#x7565;&#xFF0C;&#x76F4;&#x63A5;&#x56DE;&#x5E72;&#x6389;&#x8FC7;&#x671F;&#x7684;key</p>
<p><strong>&#x4E3A;&#x4EC0;&#x4E48;&#x4E0D;&#x7528;&#x5B9A;&#x65F6;&#x5220;&#x9664;&#x7B56;&#x7565;?</strong></p>
<p>&#x5B9A;&#x65F6;&#x5220;&#x9664;,&#x7528;&#x4E00;&#x4E2A;&#x5B9A;&#x65F6;&#x5668;&#x6765;&#x8D1F;&#x8D23;&#x76D1;&#x89C6;key,&#x8FC7;&#x671F;&#x5219;&#x81EA;&#x52A8;&#x5220;&#x9664;&#x3002;&#x867D;&#x7136;&#x5185;&#x5B58;&#x53CA;&#x65F6;&#x91CA;&#x653E;&#xFF0C;&#x4F46;&#x662F;&#x5341;&#x5206;&#x6D88;&#x8017;CPU&#x8D44;&#x6E90;&#x3002;&#x5728;&#x5927;&#x5E76;&#x53D1;&#x8BF7;&#x6C42;&#x4E0B;&#xFF0C;CPU&#x8981;&#x5C06;&#x65F6;&#x95F4;&#x5E94;&#x7528;&#x5728;&#x5904;&#x7406;&#x8BF7;&#x6C42;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x5220;&#x9664;key,&#x56E0;&#x6B64;&#x6CA1;&#x6709;&#x91C7;&#x7528;&#x8FD9;&#x4E00;&#x7B56;&#x7565;.</p>
<p><strong>&#x5B9A;&#x671F;&#x5220;&#x9664;+&#x60F0;&#x6027;&#x5220;&#x9664;&#x662F;&#x5982;&#x4F55;&#x5DE5;&#x4F5C;&#x7684;&#x5462;?</strong></p>
<p>&#x5B9A;&#x671F;&#x5220;&#x9664;&#xFF0C;redis&#x9ED8;&#x8BA4;&#x6BCF;&#x4E2A;100ms&#x68C0;&#x67E5;&#xFF0C;&#x662F;&#x5426;&#x6709;&#x8FC7;&#x671F;&#x7684;key,&#x6709;&#x8FC7;&#x671F;key&#x5219;&#x5220;&#x9664;&#x3002;&#x9700;&#x8981;&#x8BF4;&#x660E;&#x7684;&#x662F;&#xFF0C;redis&#x4E0D;&#x662F;&#x6BCF;&#x4E2A;100ms&#x5C06;&#x6240;&#x6709;&#x7684;key&#x68C0;&#x67E5;&#x4E00;&#x6B21;&#xFF0C;&#x800C;&#x662F;&#x968F;&#x673A;&#x62BD;&#x53D6;&#x8FDB;&#x884C;&#x68C0;&#x67E5;(&#x5982;&#x679C;&#x6BCF;&#x9694;100ms,&#x5168;&#x90E8;key&#x8FDB;&#x884C;&#x68C0;&#x67E5;&#xFF0C;redis&#x5C82;&#x4E0D;&#x662F;&#x5361;&#x6B7B;)&#x3002;&#x56E0;&#x6B64;&#xFF0C;&#x5982;&#x679C;&#x53EA;&#x91C7;&#x7528;&#x5B9A;&#x671F;&#x5220;&#x9664;&#x7B56;&#x7565;&#xFF0C;&#x4F1A;&#x5BFC;&#x81F4;&#x5F88;&#x591A;key&#x5230;&#x65F6;&#x95F4;&#x6CA1;&#x6709;&#x5220;&#x9664;&#x3002;</p>
<p>&#x4E8E;&#x662F;&#xFF0C;&#x60F0;&#x6027;&#x5220;&#x9664;&#x6D3E;&#x4E0A;&#x7528;&#x573A;&#x3002;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x5728;&#x4F60;&#x83B7;&#x53D6;&#x67D0;&#x4E2A;key&#x7684;&#x65F6;&#x5019;&#xFF0C;redis&#x4F1A;&#x68C0;&#x67E5;&#x4E00;&#x4E0B;&#xFF0C;&#x8FD9;&#x4E2A;key&#x5982;&#x679C;&#x8BBE;&#x7F6E;&#x4E86;&#x8FC7;&#x671F;&#x65F6;&#x95F4;&#x90A3;&#x4E48;&#x662F;&#x5426;&#x8FC7;&#x671F;&#x4E86;&#xFF1F;&#x5982;&#x679C;&#x8FC7;&#x671F;&#x4E86;&#x6B64;&#x65F6;&#x5C31;&#x4F1A;&#x5220;&#x9664;&#x3002;</p>
<p>&#x91C7;&#x7528;&#x5B9A;&#x671F;&#x5220;&#x9664;+&#x60F0;&#x6027;&#x5220;&#x9664;&#x5C31;&#x6CA1;&#x5176;&#x4ED6;&#x95EE;&#x9898;&#x4E86;&#x4E48;?</p>
<p>&#x4E0D;&#x662F;&#x7684;&#xFF0C;&#x5982;&#x679C;&#x5B9A;&#x671F;&#x5220;&#x9664;&#x6CA1;&#x5220;&#x9664;key&#x3002;&#x7136;&#x540E;&#x4F60;&#x4E5F;&#x6CA1;&#x5373;&#x65F6;&#x53BB;&#x8BF7;&#x6C42;key&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x60F0;&#x6027;&#x5220;&#x9664;&#x4E5F;&#x6CA1;&#x751F;&#x6548;&#x3002;&#x8FD9;&#x6837;&#xFF0C;redis&#x7684;&#x5185;&#x5B58;&#x4F1A;&#x8D8A;&#x6765;&#x8D8A;&#x9AD8;&#x3002;&#x90A3;&#x4E48;&#x5C31;&#x5E94;&#x8BE5;&#x91C7;&#x7528;&#x5185;&#x5B58;&#x6DD8;&#x6C70;&#x673A;&#x5236;&#x3002;</p>
<h2 id="&#x7F13;&#x5B58;&#x6DD8;&#x6C70;--eviction">&#x7F13;&#x5B58;&#x6DD8;&#x6C70;  eviction</h2>
<p>Redis&#x81EA;&#x8EAB;&#x5B9E;&#x73B0;&#x4E86;&#x7F13;&#x5B58;&#x6DD8;&#x6C70;</p>
<p>Redis&#x7684;&#x5185;&#x5B58;&#x6DD8;&#x6C70;&#x7B56;&#x7565;&#x662F;&#x6307;&#x5728;Redis&#x7684;&#x7528;&#x4E8E;&#x7F13;&#x5B58;&#x7684;&#x5185;&#x5B58;&#x4E0D;&#x8DB3;&#x65F6;&#xFF0C;&#x600E;&#x4E48;&#x5904;&#x7406;&#x9700;&#x8981;&#x65B0;&#x5199;&#x5165;&#x4E14;&#x9700;&#x8981;&#x7533;&#x8BF7;&#x989D;&#x5916;&#x7A7A;&#x95F4;&#x7684;&#x6570;&#x636E;&#x3002;</p>
<ul>
<li>noeviction&#xFF1A;&#x5F53;&#x5185;&#x5B58;&#x4E0D;&#x8DB3;&#x4EE5;&#x5BB9;&#x7EB3;&#x65B0;&#x5199;&#x5165;&#x6570;&#x636E;&#x65F6;&#xFF0C;&#x65B0;&#x5199;&#x5165;&#x64CD;&#x4F5C;&#x4F1A;&#x62A5;&#x9519;&#x3002;</li>
<li>allkeys-lru&#xFF1A;&#x5F53;&#x5185;&#x5B58;&#x4E0D;&#x8DB3;&#x4EE5;&#x5BB9;&#x7EB3;&#x65B0;&#x5199;&#x5165;&#x6570;&#x636E;&#x65F6;&#xFF0C;&#x5728;&#x952E;&#x7A7A;&#x95F4;&#x4E2D;&#xFF0C;&#x79FB;&#x9664;&#x6700;&#x8FD1;&#x6700;&#x5C11;&#x4F7F;&#x7528;&#x7684;key&#x3002;</li>
<li>allkeys-random&#xFF1A;&#x5F53;&#x5185;&#x5B58;&#x4E0D;&#x8DB3;&#x4EE5;&#x5BB9;&#x7EB3;&#x65B0;&#x5199;&#x5165;&#x6570;&#x636E;&#x65F6;&#xFF0C;&#x5728;&#x952E;&#x7A7A;&#x95F4;&#x4E2D;&#xFF0C;&#x968F;&#x673A;&#x79FB;&#x9664;&#x67D0;&#x4E2A;key&#x3002;</li>
<li>volatile-lru&#xFF1A;&#x5F53;&#x5185;&#x5B58;&#x4E0D;&#x8DB3;&#x4EE5;&#x5BB9;&#x7EB3;&#x65B0;&#x5199;&#x5165;&#x6570;&#x636E;&#x65F6;&#xFF0C;&#x5728;&#x8BBE;&#x7F6E;&#x4E86;&#x8FC7;&#x671F;&#x65F6;&#x95F4;&#x7684;&#x952E;&#x7A7A;&#x95F4;&#x4E2D;&#xFF0C;&#x79FB;&#x9664;&#x6700;&#x8FD1;&#x6700;&#x5C11;&#x4F7F;&#x7528;&#x7684;key&#x3002;</li>
<li>volatile-random&#xFF1A;&#x5F53;&#x5185;&#x5B58;&#x4E0D;&#x8DB3;&#x4EE5;&#x5BB9;&#x7EB3;&#x65B0;&#x5199;&#x5165;&#x6570;&#x636E;&#x65F6;&#xFF0C;&#x5728;&#x8BBE;&#x7F6E;&#x4E86;&#x8FC7;&#x671F;&#x65F6;&#x95F4;&#x7684;&#x952E;&#x7A7A;&#x95F4;&#x4E2D;&#xFF0C;&#x968F;&#x673A;&#x79FB;&#x9664;&#x67D0;&#x4E2A;key&#x3002;</li>
<li>volatile-ttl&#xFF1A;&#x5F53;&#x5185;&#x5B58;&#x4E0D;&#x8DB3;&#x4EE5;&#x5BB9;&#x7EB3;&#x65B0;&#x5199;&#x5165;&#x6570;&#x636E;&#x65F6;&#xFF0C;&#x5728;&#x8BBE;&#x7F6E;&#x4E86;&#x8FC7;&#x671F;&#x65F6;&#x95F4;&#x7684;&#x952E;&#x7A7A;&#x95F4;&#x4E2D;&#xFF0C;&#x6709;&#x66F4;&#x65E9;&#x8FC7;&#x671F;&#x65F6;&#x95F4;&#x7684;key&#x4F18;&#x5148;&#x79FB;&#x9664;&#x3002;</li>
</ul>
<p><strong>redis 4.x &#x540E;&#x652F;&#x6301;LFU&#x7B56;&#x7565;&#xFF0C;&#x6700;&#x5C11;&#x9891;&#x7387;&#x4F7F;&#x7528;</strong></p>
<ul>
<li><p>allkeys-lfu</p>
</li>
<li><p>volatile-lfu</p>
</li>
</ul>
<h4 id="lru">LRU</h4>
<p>LRU&#xFF08;Least recently used&#xFF0C;&#x6700;&#x8FD1;&#x6700;&#x5C11;&#x4F7F;&#x7528;&#xFF09;</p>
<p>LRU&#x7B97;&#x6CD5;&#x6839;&#x636E;&#x6570;&#x636E;&#x7684;&#x5386;&#x53F2;&#x8BBF;&#x95EE;&#x8BB0;&#x5F55;&#x6765;&#x8FDB;&#x884C;&#x6DD8;&#x6C70;&#x6570;&#x636E;&#xFF0C;&#x5176;&#x6838;&#x5FC3;&#x601D;&#x60F3;&#x662F;&#x201C;&#x5982;&#x679C;&#x6570;&#x636E;&#x6700;&#x8FD1;&#x88AB;&#x8BBF;&#x95EE;&#x8FC7;&#xFF0C;&#x90A3;&#x4E48;&#x5C06;&#x6765;&#x88AB;&#x8BBF;&#x95EE;&#x7684;&#x51E0;&#x7387;&#x4E5F;&#x66F4;&#x9AD8;&#x201D;&#x3002;</p>
<p>&#x57FA;&#x672C;&#x601D;&#x8DEF;</p>
<ol>
<li><p>&#x65B0;&#x6570;&#x636E;&#x63D2;&#x5165;&#x5230;&#x5217;&#x8868;&#x5934;&#x90E8;&#xFF1B;</p>
</li>
<li><p>&#x6BCF;&#x5F53;&#x7F13;&#x5B58;&#x547D;&#x4E2D;&#xFF08;&#x5373;&#x7F13;&#x5B58;&#x6570;&#x636E;&#x88AB;&#x8BBF;&#x95EE;&#xFF09;&#xFF0C;&#x5219;&#x5C06;&#x6570;&#x636E;&#x79FB;&#x5230;&#x5217;&#x8868;&#x5934;&#x90E8;&#xFF1B;</p>
</li>
<li><p>&#x5F53;&#x5217;&#x8868;&#x6EE1;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5C06;&#x5217;&#x8868;&#x5C3E;&#x90E8;&#x7684;&#x6570;&#x636E;&#x4E22;&#x5F03;&#x3002;</p>
</li>
</ol>
<h4 id="lfu">LFU</h4>
<p>LFU&#xFF08;Least Frequently Used &#x6700;&#x8FD1;&#x6700;&#x5C11;&#x4F7F;&#x7528;&#x7B97;&#x6CD5;&#xFF09;</p>
<p>&#x5B83;&#x662F;&#x57FA;&#x4E8E;&#x201C;&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x5728;&#x6700;&#x8FD1;&#x4E00;&#x6BB5;&#x65F6;&#x95F4;&#x5185;&#x4F7F;&#x7528;&#x6B21;&#x6570;&#x5F88;&#x5C11;&#xFF0C;&#x90A3;&#x4E48;&#x5728;&#x5C06;&#x6765;&#x4E00;&#x6BB5;&#x65F6;&#x95F4;&#x5185;&#x88AB;&#x4F7F;&#x7528;&#x7684;&#x53EF;&#x80FD;&#x6027;&#x4E5F;&#x5F88;&#x5C0F;&#x201D;&#x7684;&#x601D;&#x8DEF;&#x3002;</p>
<p><img src="../images/LFU.png" alt="lfu"></p>
<p><strong>LFU&#x9700;&#x8981;&#x5B9A;&#x671F;&#x8870;&#x51CF;&#x3002;</strong></p>
<h3 id="redis&#x6DD8;&#x6C70;&#x7B56;&#x7565;&#x7684;&#x914D;&#x7F6E;">Redis&#x6DD8;&#x6C70;&#x7B56;&#x7565;&#x7684;&#x914D;&#x7F6E;</h3>
<ul>
<li><p>maxmemory <bytes>   &#x6700;&#x5927;&#x4F7F;&#x7528;&#x5185;&#x5B58;&#x6570;&#x91CF;</bytes></p>
</li>
<li><p>maxmemory-policy noeviction  &#x6DD8;&#x6C70;&#x7B56;&#x7565;</p>
</li>
</ul>
<h3 id="&#x601D;&#x8003;&#x9898;">&#x601D;&#x8003;&#x9898;</h3>
<p>mySQL&#x91CC;&#x6709;2000w&#x6570;&#x636E;&#xFF0C;redis&#x4E2D;&#x53EA;&#x5B58;20w&#x7684;&#x6570;&#x636E;&#xFF0C;&#x5982;&#x4F55;&#x4FDD;&#x8BC1;redis&#x4E2D;&#x7684;&#x6570;&#x636E;&#x90FD;&#x662F;&#x70ED;&#x70B9;&#x6570;&#x636E;</p>
<h3 id="&#x5934;&#x6761;&#x9879;&#x76EE;&#x65B9;&#x6848;">&#x5934;&#x6761;&#x9879;&#x76EE;&#x65B9;&#x6848;</h3>
<ul>
<li><p>&#x7F13;&#x5B58;&#x6570;&#x636E;&#x90FD;&#x8BBE;&#x7F6E;&#x6709;&#x6548;&#x671F;</p>
</li>
<li><p>&#x914D;&#x7F6E;redis&#xFF0C;&#x4F7F;&#x7528;volatile-lru</p>
</li>
</ul>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../C06-Cache/CacheData.html" class="navigation navigation-prev " aria-label="Previous page: 缓存的数据"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../C06-Cache/CachePatterns.html" class="navigation navigation-next " aria-label="Next page: 缓存模式"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
